public class Practice2 {
    /*
    链接https://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49?tpId=295&tqId=23268&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj%3FquestionJobId%3D10%26subTabName%3Donline_coding_page@
    少了一些边界处理的栈
    最小栈可以使用另一个栈来进行维护, 如果遇到比最小栈栈顶元素还小的就入最小栈
     */
    //手写栈, 根据数据范围防止溢出
    public static int[] stack = new int[301];
    public static int top = 0;
    public void push(int node) {
        stack[top++] = node;
    }

    public void pop() {
        top--;
    }

    public int top() {
        //一定有元素, 无需判空
        int cur = top;
        return stack[--cur];
    }

    public int min() {
        //遍历
        int minNum = 10001;
        for(int i = 0;i < top;i++){
            minNum = Math.min(minNum,stack[i]);
        }
        return minNum;
    }

    public static void main(String[] args) {

    }
}
